﻿using IBLL;
using IDAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
    public class WorkBll : IWorkBll
    {
        public WorkBll(IYkDal<Work> dal)
        {
            Dal = dal;
        }

        public IYkDal<Work> Dal { get; }
        /// <summary>
        /// 职员信息添加
        /// </summary>
        /// <param name="work">表名</param>
        /// <returns>返回受影响行数</returns>
        public Task<int> Tian(Work work)
        {
        return Dal.Add(work);
        }
        /// <summary>
        /// 职员信息查询功能
        /// </summary>
        /// <param name="name">职员姓名</param>
        /// <param name="typess">职员类别</param>
        /// <returns></returns>
        public IQueryable<Work> Xian(string? name, string? typess)
        {
            var list = Dal.Show();
            if (!string.IsNullOrWhiteSpace(name))
            {
                list = list.Where(x => x.Name.Contains(name));
            }
            if (!string.IsNullOrWhiteSpace(typess))
            {
                list = list.Where(x => x.Type== typess);
            }
            return list;
        }
    }
}
